import matplotlib.pyplot as plt
import pandas as pd
import numpy as np
from matplotlib.widgets import Cursor
plt.rcParams['font.sans-serif'] = ['SimHei']
shu_ju=pd.read_excel('./学生课程成绩数据.xls')
data_mao=shu_ju[shu_ju['课程名称']=='毛泽东思想与中国特色社会主义理论体系概论']
data_mao=data_mao[['姓名','课程名称','分数']]
# print(data_mao['分数'])
a=0
b=0
c=0
d=0
for i in data_mao['分数']:
    if i<60:
        a+=1
    elif 60<=i<75:
        b+=1
    elif 75<=i<90:
        c+=1
    else:
        d+=1
# print(a,b,c,d)
plt.figure(figsize=(12,7))
labels=['不及格','及格','良好','优秀']
#explode饼状分离
explode=(0,0,0,0.1)
#autopct输出百分比
plt.pie([a,b,c,d],labels=labels,explode=explode,shadow=True,autopct='%3.2f%%')
plt.title("《毛概》成绩等级百分比",fontproperties='SimHei',fontsize=28,color='#ffe600')
plt.legend(loc='lower right')
plt.show()